<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'vehicle.label', default: 'Vehicle')}"/>
    <title>新增车辆</title>
</head>

<body>
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>PLS CINDATA</li>
                    <li>
                        <g:link controller="menu" action="index">CINDATA</g:link>
                    </li>
                    <li class="active">
                        <span>新增车辆</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                新增车辆
            </h2>
        </div>
    </div>
</div>

<g:form action="save">
    <g:if test="${flash.message}">
        <div class="message alert alert-info" role="status">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${this.menu}">
        <ul class="errors" role="alert">
            <g:eachError bean="${this.menu}" var="error">
                <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                        error="${error}"/></li>
            </g:eachError>
        </ul>
    </g:hasErrors>

    <div class="content animate-panel">
        <div class="row">
            <div class="hpanel hred">
                <div class="panel-heading">
                    关联贷款信息
                </div>
                <div class="panel-body form-horizontal">
                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">贷款</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" multiple="multiple" name="mortgageList" id="mortgageList" from="${com.cindata.Mortgage.list(max: 1000)}" optionValue="serialNumber" optionKey="id" value="${this?.vehicle?.mortgage?.id}" noSelection="${['': '请选择贷款']}"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="content animate-panel">
        <div class="row">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    车辆基本信息
                </div>

                <div class="panel-body form-horizontal">

                    <div class="form-group">

                        <label class="col-md-2 control-label is-required">省份</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="province" id="province" from="${com.cindata.Province.list()}" optionValue="name" optionKey="id" value="${this?.vehicle?.province?.id}" noSelection="${['': '请选择省份']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">押品状态</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="estateStatus" id="estateStatus" from="${com.cindata.dictionary.EstateStatusDict.list()}" optionValue="name" optionKey="id" value="${this?.vehicle?.estateStatus?.id}" noSelection="${['': '请选择押品状态']}"/>
                        </div>

                        <label class="col-md-2 control-label is-required">城市</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="city" id="city" from="${com.cindata.City.findAllByNameInList(new com.cindata.ComponentService().evaluate(com.cindata.Component.findByCode('showCity')), [sort: 'name', order: 'asc'])}" optionValue="name" optionKey="id" value="${this?.vehicle?.city?.id}" noSelection="${['': '请选择市']}"/>
                        </div>
                        
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">是否在押</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="isEstate" id="isEstate" value="${this.vehicle?.isEstate}"/>
                        </div>

                        <label class="col-md-2 control-label is-required">区域</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="district" id="district" from="${com.cindata.District.list()}" optionValue="name" optionKey="id" value="${this?.vehicle?.district?.id}" noSelection="${['': '请选择区域']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">评估单价</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="unitPrice" id="unitPrice" value="${this.vehicle?.unitPrice}"/>
                        </div>

                        <label class="col-md-2 control-label is-required">评估总价</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="totalPrice" id="totalPrice" value="${this.vehicle?.totalPrice}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">评估时间</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="valuationDate" value="${new Date()}" precision="minute"/>
                        </div>

                        <label class="col-md-2 control-label is-required">抵押率 （%）</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="ltv" id="ltv" value="${this.vehicle?.ltv}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">直属管理机构</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="account" id="account" from="${com.cindata.Account.findAllByType(com.cindata.dictionary.AccountTypeDict.BANK())}" optionValue="name" optionKey="id" value="${this?.vehicle?.account?.id}" noSelection="${['': '请选择直属管理机构']}"/>
                        </div>

                        <label class="col-md-2 control-label is-required">动态抵押率 （%）</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="cltv" id="cltv" value="${this.vehicle?.cltv}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label is-required">贷款状态</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="mortgageStatus" id="mortgageStatus" from="${com.cindata.dictionary.MortgageStatusDict.list()}" optionValue="name" optionKey="id" value="${this?.vehicle?.mortgageStatus?.id}" noSelection="${['': '请选择贷款状态']}"/>
                        </div>
                    </div>                    
                </div>
            </div>
        </div>
    </div>

    <div class="content animate-panel">
        <div class="row">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    车辆主体信息
                </div>

                <div class="panel-body form-horizontal">

                    <div class="form-group">
                        <label class="col-md-2 control-label">质押物编号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="externalId" id="externalId" value="${this.vehicle?.externalId}"/>
                        </div>

                        <label class="col-md-2 control-label">质押物类型</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="type" id="type" from="${com.cindata.dictionary.VehicleTypeDict.list()}" optionValue="name" optionKey="id" value="${this.vehicle?.type?.id}" noSelection="${['': '请选择质押物类型']}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">质押物名称</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="name" id="name" value="${this.vehicle?.name}"/>
                        </div>
                        <label class="col-md-2 control-label">抵押人名称</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="fullName" id="fullName" value="${this.vehicle?.fullName}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">抵押人证件类型</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="identityType" id="identityType" from="${com.cindata.dictionary.ContactIdentityType.list()}" optionValue="name" optionKey="id" value="${params?.identityType}" noSelection="${['': '请选择抵押人证件类型']}"/>
                        </div>
                        <label class="col-md-2 control-label">抵押人证件号码</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="idNumber" id="idNumber" value="${this.vehicle?.idNumber}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">抵押人贷款卡编号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="loanCardNumber" id="loanCardNumber" value="${this.vehicle?.loanCardNumber}"/>
                        </div>
                        <label class="col-md-2 control-label">其他共同所有人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="commonOwnerFullName" id="commonOwnerFullName" value="${this.vehicle?.commonOwnerFullName}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">所占份额</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="sharePoint" id="sharePoint" value="${this.vehicle?.sharePoint}"/>
                        </div>
                        <label class="col-md-2 control-label">此抵押物是否当前申请所购资产</label>
                        <div class="col-md-3">
                            <g:select class="form-control" name="isApplayPurchaseAsset" id="isApplayPurchaseAsset" from="${['true','false']}" value="${this.vehicle?.isApplayPurchaseAsset}" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">抵押权顺位</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="rightOfMortgage" id="rightOfMortgage" value="${this.vehicle?.rightOfMortgage}"/>
                        </div>
                        <label class="col-md-2 control-label">在先担保金额</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="firstGuaranteedAmount" id="firstGuaranteedAmount" value="${this.vehicle?.firstGuaranteedAmount}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">抵押物品牌（品牌）</label>
                        <div class="col-md-3" >
                            <g:textField class="form-control" type="text" name="brand" id="brand" value="${this.vehicle?.brand}"/>
                        </div>
                        <label class="col-md-2 control-label">制造厂家</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="manufacturer" id="manufacturer" value="${this.vehicle?.manufacturer}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">车辆型号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="model" id="model" value="${this.vehicle?.model}"/>
                        </div>
                        <label class="col-md-2 control-label">发动机号码</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="engineNumber" id="engineNumber" value="${this.vehicle?.engineNumber}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">抵押登记证书编号（注册号）</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="mortgageRegisterNo" id="mortgageRegisterNo" value="${this.vehicle?.mortgageRegisterNo}"/>
                        </div>
                        <label class="col-md-2 control-label">生产日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="releaseDate" value="${new Date()}" precision="minute"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">购置日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="purchaseDate" value="${new Date()}" precision="minute"/>
                        </div>
                        <label class="col-md-2 control-label">购置价格</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="purchasePrice" id="purchasePrice" value="${this.vehicle?.purchasePrice}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">币种</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="currency" id="currency" from="${com.cindata.dictionary.CurrencyDict.list()}" optionValue="name" optionKey="id" value="${this.vehicle?.currency?.id}" noSelection="${['': '请选择币种']}"/>
                        </div>
                        <label class="col-md-2 control-label">使用情况</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="usage" id="usage" value="${this.vehicle?.usage}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">承租人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="lessee" id="lessee" value="${this.vehicle?.lessee}"/>
                        </div>
                        <label class="col-md-2 control-label">租赁起始日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="leaseStartDate" value="${new Date()}" precision="minute"/>
                        </div>

                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">租赁到期日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="leaseEndDate" value="${new Date()}" precision="minute"/>
                        </div>
                        <label class="col-md-2 control-label">日租金（元）</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="dailyRents" id="dailyRents" value="${this.vehicle?.dailyRents}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">变现能力</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="cashability" id="cashability" from="${com.cindata.dictionary.Cashability.list()}" optionValue="name" optionKey="id" value="${this.vehicle?.cashability?.id}" noSelection="${['': '请选择变现能力']}"/>
                        </div>

                        <label class="col-md-2 control-label">价值波动性</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="valueVolatility" id="valueVolatility" value="${this.vehicle?.valueVolatility}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">查封便利性</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="seizureOfConvenience" id="seizureOfConvenience" value="${this.vehicle?.seizureOfConvenience}"/>
                        </div>
                        <label class="col-md-2 control-label">抵质押物与借款人相关性</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="relationOfMortgagor" id="relationOfMortgagor" value="${this.vehicle?.relationOfMortgagor}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">法律有效性</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="legalValidity" id="legalValidity" value="${this.vehicle?.legalValidity}"/>
                        </div>
                        <label class="col-md-2 control-label"> 初次评估价值</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="firstEvaluatePrice" id="firstEvaluatePrice" value="${this.vehicle?.firstEvaluatePrice}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">初次评估机构</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="firstEvaluateAccount" id="firstEvaluateAccount" from="${com.cindata.Account.findAllByType(com.cindata.dictionary.AccountTypeDict.EVALUATE())}" optionValue="name" optionKey="id" value="${this.vehicle?.firstEvaluateAccount}" noSelection="${['': '请选择初次评估机构']}"/>
                        </div>
                        <label class="col-md-2 control-label">最新评估价值</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="latestEvaluatePrice" id="latestEvaluatePrice" value="${this.vehicle?.latestEvaluatePrice}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">最新评估机构</label>
                        <div class="col-md-3">
                            <g:select class="form-control m-b" name="latestEvaluateAccount" id="latestEvaluateAccount" from="${com.cindata.Account.findAllByType(com.cindata.dictionary.AccountTypeDict.EVALUATE())}" optionValue="name" optionKey="id" value="${this.vehicle?.latestEvaluateAccount}" noSelection="${['': '请选择最新评估机构']}"/>
                        </div>
                        <label class="col-md-2 control-label">最新评估日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="latestEvaluateDate" value="${new Date()}" precision="minute"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">下次评估日期</label>
                        <div class="col-md-3">
                            <g:datePicker class="form-control" name="nextEvaluateDate" value="${new Date()}" precision="minute"/>
                        </div>
                        <label class="col-md-2 control-label">实际抵质押率</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="actualMortgageRate" id="actualMortgageRate" value="${this.vehicle?.actualMortgageRate}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">抵质押率上限</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="mortgageRateUpperLimit" id="mortgageRateUpperLimit" value="${this.vehicle?.mortgageRateUpperLimit}"/>
                        </div>
                        <label class="col-md-2 control-label">抵质押物说明</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="description" id="description" value="${this.vehicle?.description}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">登记人</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="registerFullName" id="registerFullName" value="${this.vehicle?.registerFullName}"/>
                        </div>
                        <label class="col-md-2 control-label">登记机构</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="registerAccount" id="registerAccount" value="${this.vehicle?.registerAccount}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-2 control-label">登记日期</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="registerDate" id="registerDate" value="${this.vehicle?.registerDate}"/>
                        </div>
                        <label class="col-md-2 control-label">更新日期</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="registerUpdateDate" id="registerUpdateDate" value="${this.vehicle?.registerUpdateDate}"/>
                        </div>
                    </div>

                    <div class="form-group">

                        <label class="col-md-2 control-label">行驶里程</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="mileage" id="mileage" value="${this.vehicle?.mileage}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">车牌号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="plateNumber" id="plateNumber" value="${this.vehicle?.plateNumber}"/>
                        </div>

                        <label class="col-md-2 control-label">车架号</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="identificationNumber" id="identificationNumber" value="${this.vehicle?.identificationNumber}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-md-2 control-label">是否新车</label>
                        <div class="col-md-3">
                            <g:select class="form-control" name="isNew" id="isNew" from="${['true','false']}" value="${this.vehicle?.isNew}"/>
                        </div>

                        <label class="col-md-2 control-label">车辆状况</label>
                        <div class="col-md-3">
                            <g:textField class="form-control" type="text" name="condition" id="externalId" value="${this.vehicle?.condition}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-3 col-md-offset-6">
                            <g:submitButton class="btn btn-info" name="create" value="保存"/>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

</g:form>

<g:javascript>
$(function () {
$('.datepicker').datepicker({
language: 'zh-CN',
format:"yyyy-mm-dd"
});
$('.input-group.date').datepicker({ });
$('.input-daterange').datepicker({ });
});

// $("#city").bind("change", function(){
//     $("#district option").remove();
//     $("#s2id_district span:first").html("请选择行政区");
//     var city = $("#city").val()
//     $("#district").append("<option value='-1' >请选择行政区</option>")
//     if(city=='-1'){
//         return
//     }
//     $.ajax({
//         url: "/estate/districtList",
//         type: "POST",
//         data: {'city': city} ,
//         success: function(result){
//             for(var i=0; i < result.districtList.length; i++){
//                 $("#district").append("<option value=" + result.districtList[i].zoneNumber + ">" + result.districtList[i].name + "</option>")
//             }
//         }
//     });
// });
// $("#city").change();

</g:javascript>
</body>
</html>
